(function(){"use strict";BX.namespace("BX.UI");BX.UI.DropdownMenu=function(e){this.container=e.container;this.items=[]};BX.UI.DropdownMenu.prototype={init:function(){var e=this.container.querySelectorAll(".ui-sidepanel-menu-item");for(var t=0;t<e.length;t++){var i={};i.id=t;i.container=null;i.link=null;i.button=null;i.submenu=null;i.container=e[t];i.link=i.container.querySelector(".ui-sidepanel-menu-link");i.operativeItem=i.link.getAttribute("bx-operative")==="Y";this.items.push(i);if(i.container.classList.contains("ui-sidepanel-menu-active")){i.activeItem=true}if(i.container.querySelector(".ui-sidepanel-menu-notice-icon")){i.noticeItem=true}}this.loadData()},loadData:function(){for(var e=0;e<this.items.length;e++){this.addItem(this.items[e])}},addItem:function(e){var t=new BX.UI.DropdownMenuItem(e);t.menu=this;this.items[e.id]=t},resetItems:function(){for(var e=0;e<this.items.length;e++){if(this.items[e].activeItem){this.items[e].reset()}}},resetSubItems:function(){for(var e=0;e<this.items.length;e++){this.items[e].resetSubItems()}}};var e=new WeakMap;BX.UI.DropdownMenuItem=function(t){this.container=t.container;this.link=t.link;this.button=null;this.activeItem=t.activeItem?t.activeItem:null;this.noticeItem=t.noticeItem?t.noticeItem:null;this.operativeItem=t.operativeItem?t.operativeItem:null;this.submenu=null;this.subItems=[];this.submenuOpen=false;this.newBadge=null;this.counter=null;this.addItem=null;this.init();e.set(this.container,this)};BX.UI.DropdownMenuItem.getItemByNode=function(t){if(BX.Dom.hasClass(t,"ui-sidepanel-menu-link")){return e.get(t.parentNode)}return e.get(t)};BX.UI.DropdownMenuItem.prototype={init:function(){if(this.isSubmenuExist()){this.submenu=this.container.querySelector(".ui-sidepanel-submenu");this.button=this.getToggleButton();this.link.appendChild(this.button)}var e=this.container.querySelectorAll(".ui-sidepanel-submenu-item"),t=false;for(var i=0;i<e.length;i++){var n={};n.id=i;n.container=e[i];this.subItems.push(n);if(n.container.classList.contains("ui-sidepanel-submenu-active")){n.activeSubItem=true;t=true}}this.loadData();if(this.isSubmenuExist()&&(this.activeItem===true&&this.operativeItem===true||t===true)){this.showSubmenu();this.setNewToggleButtonName()}this.loadData();this.addEvents()},loadData:function(){for(var e=0;e<this.subItems.length;e++){this.addSubItem(this.subItems[e])}},activate:function(){this.activeItem=true;this.container.classList.add("ui-sidepanel-menu-active")},reset:function(){this.activeItem=null;this.container.classList.remove("ui-sidepanel-menu-active")},addNoticeIcon:function(){this.noticeItem=true;if(!this.container.querySelector(".ui-sidepanel-menu-notice-icon")){this.container.children[0].appendChild(this.getNoticeIcon())}},removeNoticeIcon:function(){this.noticeItem=null;if(this.container.querySelector(".ui-sidepanel-menu-notice-icon")){this.container.querySelector(".ui-sidepanel-menu-notice-icon").remove()}},getNoticeIcon:function(){this.noticeIcon=document.createElement("span");this.noticeIcon.className="ui-sidepanel-menu-notice-icon";return this.noticeIcon},showSubmenu:function(){this.submenuOpen=true;this.submenu.style.height=this.getSubmenuHeight()},hideSubmenu:function(){this.submenuOpen=false;this.submenu.style.height=0},getSubmenuHeight:function(){var e=0;for(var t=0;t<this.subItems.length;t++){e=e+(this.subItems[t].getHeight()+6-3)}return e+"px"},addEvents:function(){this.link.addEventListener("click",this.setActiveHandler.bind(this))},setActiveHandler:function(e){this.menu.resetItems();this.activate();if(this.link.getAttribute("bx-operative")!=="Y"){this.link.classList.add("ui-sidepanel-menu-disable-active-state")}else{this.link.classList.remove("ui-sidepanel-menu-disable-active-state")}if(this.isSubmenuExist()){if(!this.submenuOpen){this.showSubmenu();this.setNewToggleButtonName();this.menu.resetSubItems();e&&e.preventDefault()}else{this.hideSubmenu();this.setDefaultToggleButtonName();this.menu.resetSubItems();e&&e.preventDefault()}}else{if(this.link.classList.contains("ui-sidepanel-menu-disable-active-state")){this.link.classList.remove("ui-sidepanel-menu-disable-active-state")}this.menu.resetSubItems()}},isSubmenuExist:function(){if(this.container.querySelector(".ui-sidepanel-submenu")){return true}return false},getToggleButton:function(){this.buttonContainer=document.createElement("div");this.buttonContainer.className="ui-sidepanel-toggle-btn";this.setDefaultToggleButtonName();return this.buttonContainer},setNewToggleButtonName:function(){this.buttonContainer.innerHTML=BX.message("UI_SIDEPANEL_MENU_BUTTON_CLOSE")},setDefaultToggleButtonName:function(){this.buttonContainer.innerHTML=BX.message("UI_SIDEPANEL_MENU_BUTTON_OPEN")},getNewItemBadge:function(){this.itemBadgeNewContainer=document.createElement("div");this.itemBadgeNewContainer.className="ui-sidepanel-badge-new";return this.itemBadgeNewContainer},getCounter:function(){this.counterContainer=document.createElement("span");this.counterContainer.className="ui-sidepanel-counter";return this.counterContainer},getAddItem:function(){this.addItemContainer=document.createElement("a");this.addItemContainer.className="ui-sidepanel-add-item";this.setAddItemName();return this.addItemContainer},setAddItemName:function(){this.addItemContainer.innerHTML=BX.message("UI_SIDEPANEL_MENU_ADD_ITEM")},addSubItem:function(e){var t=new BX.UI.DropdownMenuSubItem(e);t.subMenu=this;this.subItems[e.id]=t},resetSubItems:function(){for(var e=0;e<this.subItems.length;e++){if(this.subItems[e].activeSubItem){this.subItems[e].reset()}}}};BX.UI.DropdownMenuSubItem=function(e){this.container=e.container;this.id=e.id;this.activeSubItem=e.activeSubItem?e.activeSubItem:null;this.subMenu=null;this.init()};BX.UI.DropdownMenuSubItem.prototype={init:function(){this.addEvents()},activate:function(){this.activeSubItem=true;this.container.classList.add("ui-sidepanel-submenu-active")},reset:function(){this.activeSubItem=null;this.container.classList.remove("ui-sidepanel-submenu-active")},addEvents:function(){this.container.addEventListener("click",function(){if(this.activeSubItem){return}if(!this.activeSubItem&&!this.activeItem){this.subMenu.menu.resetItems()}this.subMenu.menu.resetSubItems();this.subMenu.resetSubItems();this.activate()}.bind(this))},getHeight:function(){return this.container.offsetHeight}}})();
//# sourceMappingURL=script.map.js